<HTML>
    <HEAD>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>CPU信息测试页面</title>
  <script type="text/javascript" src="./js/service.js"></script>
  <script type="text/javascript" src="./js/jquery-1.9.1.min.js"></script>
  <script src="./js/qwebchannel.js"></script>
      <TITLE>CPU信息测试页面</TITLE>
      <SCRIPT language=JavaScript>
              var websocket_url = 'ws://localhost:12345';
              var websocket = null;

              if (websocket === null) {
                  websocket = new WebSocket(websocket_url);
                  websocket.onopen = function () {
                      console.log("connect websocketserver success");
                  }
              } else {
                  websocket.close();
                  websocket = null;
              }

              function getCpuArch() {
                  console.log("getCpuArch")
                  new QWebChannel(websocket,function(channel){
                          var cpuinfo = channel.objects.cpuinfo;
                          cpuinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          cpuinfo.getCpuArch();
                          }
                      );
              }
              function getCpuVendor() {
                  console.log("getCpuVendor")
                  new QWebChannel(websocket,function(channel){
                          var cpuinfo = channel.objects.cpuinfo;
                          cpuinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          cpuinfo.getCpuVendor();
                          }
                      );
              }
              function getCpuModel() {
                  console.log("getCpuModel")
                  new QWebChannel(websocket,function(channel){
                          var cpuinfo = channel.objects.cpuinfo;
                          cpuinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          cpuinfo.getCpuModel();
                          }
                      );
              }
              function getCpuFreqMHz() {
                  console.log("getCpuFreqMHz")
                  new QWebChannel(websocket,function(channel){
                          var cpuinfo = channel.objects.cpuinfo;
                          cpuinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          cpuinfo.getCpuFreqMHz();
                          }
                      );
              }
              function getCpuCorenums() {
                  console.log("getCpuCorenums")
                  new QWebChannel(websocket,function(channel){
                          var cpuinfo = channel.objects.cpuinfo;
                          cpuinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          cpuinfo.getCpuCorenums();
                          }
                      );
              }

              function getCpuVirt() {
                  console.log("getCpuVirt")
                  new QWebChannel(websocket,function(channel){
                          var cpuinfo = channel.objects.cpuinfo;
                          cpuinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          cpuinfo.getCpuVirt();
                          }
                      );
              }
              function getCpuProcess() {
                  console.log("getCpuProcess")
                  new QWebChannel(websocket,function(channel){
                          var cpuinfo = channel.objects.cpuinfo;
                          cpuinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          cpuinfo.getCpuProcess();
                          }
                      );
              }
        //-->
      </SCRIPT>
      <META content="MSHTML 6.00.2900.6287" name=GENERATOR>
      <style>
        table tr td{padding: 5px;}
      </style>
  
    </HEAD>
    <BODY>
      <div style="margin:30 5 20 5">
        <div>
          <input onclick="getCpuArch()" type="button" value="CPU架构"  style="width: 120px; height: 50px">
          <input onclick="getCpuVendor()" type="button" value="CPU制造厂商"  style="width: 100px; height: 50px">
          <input onclick="getCpuModel()" type="button" value="CPU型号"  style="width: 100px; height: 50px">
          <input onclick="getCpuFreqMHz()" type="button" value="CPU额定主频"  style="width: 100px; height: 50px">
          <input onclick="getCpuCorenums()" type="button" value="CPU核心数量"  style="width: 100px; height: 50px">
          <input onclick="getCpuVirt()" type="button" value="对虚拟化的支持"  style="width: 120px; height: 50px">
          <input onclick="getCpuProcess()" type="button" value="CPU线程数"  style="width: 100px; height: 50px">
        </div>
        <div style="margin-top:20">
          <div align=left style="margin:5 0 5 0">回复：</div>
          <div>
          <textarea id="res" style="width:1000px;height:500px" ></textarea>
          </div>
        </div>
      </div>
    </BODY>
  </HTML>